Skip to content

fix: HTTPWalletWire uses injected httpClient instead of global fetch#224

Merged
sirdeggen merged 1 commit into
bsv-blockchain:mainfrom
iiamboss:fix/httpwalletwire-injected-httpclient
Jun 23, 2026
Merged

fix: HTTPWalletWire uses injected httpClient instead of global fetch#224
sirdeggen merged 1 commit into
bsv-blockchain:mainfrom
iiamboss:fix/httpwalletwire-injected-httpclient

Conversation

@iiamboss

Copy link
Copy Markdown
Contributor

Problem

HTTPWalletWire accepts and stores an httpClient constructor parameter, but transmitToWallet calls the global fetch directly — so the injected client is silently dropped.

This makes it impossible to:

  • wrap requests with AuthFetch for BRC-103 mutual authentication (auth headers are dropped → requests go out unauthenticated and are rejected by an auth-protected server);
  • inject a custom fetch (timeouts/proxy/retries/headers) or a mock for testing.

The sibling substrate HTTPWalletJSON already uses its injected httpClient, so this is an inconsistency rather than intentional — it dates back to when the HttpClient abstraction was replaced with native fetch: the constructor parameter was kept and re-typed to typeof fetch, but the body was changed to call the global fetch(...) instead of this.httpClient(...).

Fix

transmitToWallet now calls this.httpClient instead of the global fetch. Because httpClient defaults to the global fetch, existing behavior is unchanged.

Tests

  • Added a regression test asserting the injected client is used (and the global fetch is not). It fails without this fix and passes with it.
  • Updated a stale comment and test name that documented the old behavior.
  • All existing HTTPWalletWire tests pass (44/44).

transmitToWallet called the global fetch directly, silently dropping the
injected httpClient. This prevented wrapping requests with AuthFetch for
BRC-103 mutual auth and prevented injecting a custom/mock fetch. The sibling
HTTPWalletJSON already uses its injected httpClient. With the default
constructor httpClient defaults to global fetch, so existing behavior is
preserved.

Adds a regression test asserting the injected client is used; fixes a stale
comment/test name that documented the old behavior.
@sirdeggen sirdeggen merged commit daf708c into bsv-blockchain:main Jun 23, 2026
7 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants